/*
 * channeldata.h
 *
 *  Created on: Nov 16, 2009
 *      Author: zaca
 */

#ifndef CHANNELDATA_H_
#define CHANNELDATA_H_

#include <biosignal/signaldata.h>

#include <tr1/memory>
#include <vector>

namespace biosignal {
class DataFrame;

namespace montage {
class Channel;

using namespace std::tr1;

class ChannelData;

class ChannelDataIterator : public std::iterator<std::forward_iterator_tag,
            double, long>
{
public:
    ChannelDataIterator() {};
    ChannelDataIterator(const ChannelData* channel_data, long current_id=0);
    bool operator==(const ChannelDataIterator & other) const;
    bool operator!=(const ChannelDataIterator& other) const;
    double operator*() const;
    ChannelDataIterator& operator++();
    ChannelDataIterator& operator--();
    ChannelDataIterator operator++(int);
private:
    const ChannelData* m_channel_data;
    long m_current_id;
};



class ChannelData {
public:
    ChannelData(const Channel* channel, const DataFrame* data_frame);
    virtual ~ChannelData();
    virtual double value(unsigned int sample_nr) const = 0;
    virtual int size() const = 0;
    const Channel * channel() const;
    const DataFrame * data_frame() const;

    ChannelDataIterator begin() const;
    ChannelDataIterator end() const;
private:
    const Channel* m_channel;
    const DataFrame* m_dataframe;

};

typedef shared_ptr<ChannelData> ChannelDataType;

class RefChannel;
class RefChannelData: public ChannelData {
public:
    RefChannelData(const RefChannel* channel, const DataFrame* data_frame);
    virtual double value(unsigned int sample_nr) const;
    virtual int size() const;
private:
    shared_ptr<const SignalData> m_signal_data;

};


}
}

#endif /* CHANNELDATA_H_ */
